All Questions
15 questions
0votes
1answer
305views
Is it ok to Inject a whole object instead of only the dependencies
I'm working with the Dependency Injection Pattern in Unity3D (an engine which uses MonoBehavior, a class that doesn't have a constructor, as the base class for all of its game components), and I ended ...
0votes
3answers
328views
How to choose between these different options for communicating between objects?
I have a few objects that should communicate between each other. I also want to have my code unit tested. I am questioning how I should handle their communication: Should I make one instantiate the ...
5votes
1answer
2kviews
How to handle the Dependencies between Secondary Actor Adapters in the Hexagonal Architecture
I am applying the principles of Hexagonal Architecture (Ports and Adapters) and one aspect is slightly bothering me. In my opinion, the ports and adapters of the secondary actors should completely be ...
3votes
1answer
255views
What are the pros and cons of keeping most of an application's state in a single struct?
In my application, I have a few classes. Many of these classes share common state like a reference to the logger for example. For example, both A and B require some common state to get their job done. ...
172votes
8answers
83kviews
Criticism and disadvantages of dependency injection
Dependency injection (DI) is a well known and fashionable pattern. Most of engineers know its advantages, like: Making isolation in unit testing possible/easy Explicitly defining dependencies of a ...
9votes
3answers
15kviews
React Native - Is using a singleton the best alternative to DI?
I've been reading a lot about the singleton pattern and how it's "bad" because it makes the classes using it hard to test so it should be avoided. I've read some articles explaining how the singleton ...
3votes
1answer
2kviews
Connect observers to observable automatically using dependency injection container
I have several services that implement an observer interface and one service that implements the corresponding observable interface. I'm currently using unity together with Prism so I would prefer to ...
6votes
2answers
7kviews
Circular dependency in dependency injection
we're quite new to DI and we're refactoring our application to use Prism/Unity. We're almost there but got stuck on a circular dependency. I've been reading a lot, there are a lot of similar questions ...
0votes
1answer
882views
Dealing with multiple user session types in DDD
I am developing an application which will use user sessions stored both in the client and on servers. Should I treat them as different repository implementations and use DI to use them inside domain ...
0votes
1answer
294views
How to use dependency injection for applications that are configurable at startup?
I'm writing software that needs to be fairly configurable in nature. At this point what that means is that it first reads in a users configuration file and then builds the objects it needs based on ...
8votes
2answers
5kviews
How can I avoid tight coupling when practically every decision-logic has to check lots of distributed state?
As the senior developer in our company, I am currently starting to move our commercial php-mysql e-commerce solution (which takes data from a specific ERP-system) from procedural spaghetti-code which ...
0votes
2answers
4kviews
Can Dependency Injection used as an alternative to Reflection for creating instances
There is a piece of .net C# code which use Reflection to create an instance using Activator.CreateInstance(). This is an old piece of code and runs on the top of Enterprise Library. Is it a better ...
1vote
1answer
679views
Architecting Domain Layer and other modules with dependency injection in mind
I am currently new to Dependency Injection pattern. I am influenced by link by Mark Seemann. I have a confusion regarding whether an interface for an agent class of some agent module should be ...
1vote
2answers
1kviews
Very-Loose Coupling and Dependency Injection for Database Management
I'm currently setting up a MongoDB database for a web-app. I'm running node.js and using Mongoose to help manage mapping, validation ect. I'm wondering if it's a good idea to really decouple MongoDB ...
4votes
1answer
4kviews
DI / IoC Abstract Factory Galore
Given a project architecture as follows, where each box represents an assembly (all are class libraries), and each arrow stands for a dependency: Might be worth nothing that this project is massive (...